package com.cruise.h5.controller;


import com.cruise.common.web.result.Result;
import com.cruise.common.web.util.WebUtils;
import com.cruise.h5.pojo.vo.CategoryListVO;
import com.cruise.h5.pojo.vo.LabelListVO;
import com.cruise.h5.service.CategoryService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author cruise
 * @since 2021-03-25
 */
@RestController
@RequestMapping("/h5/category")
public class CategoryController {

    @Resource
    private CategoryService categoryService;

    /**
     * 分区列表
     * @return
     */
    @ApiOperation("分类列表")
    @PostMapping("/categoryList")
    public Result categoryList(){
        List<CategoryListVO> categoryListVOList = categoryService.categoryList();
        return Result.success(categoryListVOList);
    }

    /**
     * 标签，自定义标签和推荐标签
     * @return
     */
    @ApiOperation("自定义标签和推荐标签")
    @PostMapping("/labelList")
    public Result labelList(String categoryId){
        List<LabelListVO.RecommendLabelVO> categoryListVOList = categoryService.recommedLabelList(categoryId);
        List<LabelListVO.CustomizedLabelVO> customizedLabelVOList = categoryService.customizeLabelList(WebUtils.getUserId());
        LabelListVO labelListVO = new LabelListVO(customizedLabelVOList, categoryListVOList);
        return Result.success(labelListVO);
    }

}

